SKLearn predictor - Regressor


ATT hit predictor.

</span>
This notebook shows how the hit predictor works.
The Hit predictor aim is to guess (x,y) coords from serial port readings. There are two steps: Train and Predict.

Set modules path first:


In [1]:
import sys
#sys.path.insert(0, 'I:/git/att/src/python/')
sys.path.insert(0, 'i:/dev/workspaces/python/att-workspace/att/src/python/')

Build a processor.
This is required by the regressor in order to parse the input raw data.
A ATTPlainHitProcessor is needed here.


In [2]:
from hit.process.processor import ATTPlainHitProcessor

plainProcessor = ATTPlainHitProcessor()

We build the regressor now, injecting the processor


In [3]:
from hit.train.regressor import ATTSkLearnHitRegressor
regressor = ATTSkLearnHitRegressor(plainProcessor)

We define the training data source file


In [4]:
TRAIN_VALUES_FILE_LEFT = "train_data/train_points_20160129_left.txt"

And load the dataset


In [5]:
import numpy as np

(training_values, Y) = regressor.collect_train_hits_from_file(TRAIN_VALUES_FILE_LEFT)
print "Train Values: ", np.shape(training_values), np.shape(Y)


Train Values:  (20L, 8L) (20L, 2L)

Now, train


In [6]:
regressor.train(training_values, Y)

And finally test


In [7]:
hit = "hit: {1568:6 1416:5 3230:6 787:8 2757:4 0:13 980:4 3116:4 l}"
print '(6,30)'
print regressor.predict(hit)


(6,30)
[[  6.58903095  27.58995663]]
----------
(6.5890309474363136, 27.58995663174084)
C:\Users\asanso\Anaconda2\lib\site-packages\sklearn\utils\validation.py:386: DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17 and willraise ValueError in 0.19. Reshape your data either using X.reshape(-1, 1) if your data has a single feature or X.reshape(1, -1) if it contains a single sample.
  DeprecationWarning)

In [ ]:


In [ ]: